Function.RegisterNamespace("Test.System.IO");

[Fixture,Trait("Integration")]
Test.System.IO.DirectoryStrategy=function(){
    var fileSystemError="The method or file system does not appear to be implemented. Please implement System.IO.Directory.IDirectoryStrategy and register the Function pointer with System.IO.Directory.Strategies.Add(type)";

    [Fixture]
    function Exists(){
        [Fact]
        function ReturnsTrueIfDirectoryExists(){
            var targetDirectory=System.Environment.GetWorkingDirectory();
            
            var actual=System.IO.Directory.Exists(targetDirectory);
            
            Assert.True(actual,String.Format("Test.System.IO.DirectoryStrategy.Exists.ReturnsTrueIfDirectoryExists: {0}",fileSystemError));
        }

        [Fact]
        function ReturnsFalseIfFileDoesNotExist(){
            var actual=System.IO.Directory.Exists('');
            
            Assert.False(actual,String.Format("Test.System.IO.DirectoryStrategy.Exists.ReturnsFalseIfDirectoryDoesNotExist: {0}",fileSystemError));
        }
    }
    
    [Fixture]
    function GetFiles(){
        [Fact]
        function ReturnsAnArrayIfPathDoesNotExist(){
            var actual=System.IO.Directory.GetFiles('');
            
            Assert.True(Object.IsType(Array,actual));
        }

        [Fact]
        function ReturnsEmptyArrayIfPathDoesNotExist(){
            var actual=System.IO.Directory.GetFiles('');
            
            Assert.True(actual.length==0);
        }
        
        [Fact]
        function ReturnsAnArrayOfFilesIfPathExists(){
            var targetDirectory=System.Environment.GetWorkingDirectory();

            var actual=System.IO.Directory.GetFiles(targetDirectory);
            
            Assert.True(Object.IsType(Array,actual));
        }
    }
    
    [Fixture]
    function GetDirectories(){
        [Fact]
        function ReturnsAnArrayIfPathDoesNotExist(){
            var actual=System.IO.Directory.GetDirectories('');
            
            Assert.True(Object.IsType(Array,actual));
        }

        [Fact]
        function ReturnsEmptyArrayIfPathDoesNotExist(){
            var actual=System.IO.Directory.GetDirectories('');
            
            Assert.True(actual.length==0);
        }
        
        [Fact]
        function ReturnsAnArrayOfDirectoriesIfPathExists(){
            var targetDirectory=System.Environment.GetWorkingDirectory();

            var actual=System.IO.Directory.GetDirectories(targetDirectory);
            
            Assert.True(Object.IsType(Array,actual));
        }

        [Fact]
        function ReturnsNonEmptyArrayIfPathExists(){
            var targetDirectory=System.Environment.GetWorkingDirectory();

            var actual=System.IO.Directory.GetDirectories(targetDirectory);
            
            Assert.True(actual.length>0);
        }

    }
}
